/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package umbook.dao;

import org.hibernate.Session;
import umbook.entity.HibernateUtil;
import umbook.entity.Usuarios;
import java.util.List;
import org.hibernate.Query;

/**
 *
 * @author marce
 */
public class AmistadDAO {
    
    Session session;

    public AmistadDAO() {
        this.session = HibernateUtil.getSessionFactory().getCurrentSession();
    }
    
    public List<Usuarios> verificarAmistad(int idUser, int idAmigo){
    
         List<Usuarios> amigosList = null;
        try {
            org.hibernate.Transaction tx = session.beginTransaction();
            Query q = session.createSQLQuery("SELECT * FROM MiembrosGA mga INNER JOIN GruposAmigos ga ON mga.idGrupo = ga.idGrupo WHERE idUser = " + idUser + " AND mga.idMiembro = " + idAmigo);
            

            amigosList = (List<Usuarios>) q.list();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return amigosList;
        
    }

}
